package methodReferences;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * 类名：MainTest
 * 开发人员: CoderJu
 * 创建时间: 2019/3/4 21:27
 * 描述:
 * 版本：V1.0
 */
public class MainTest {

    public static void main(String[] args) {
        Student s1 = new Student("张三",80);
        Student s2 = new Student("李四",90);
        Student s3 = new Student("王五",70);
        Student s4 = new Student("赵六",65);
        Student s5 = new Student("钱多多",98);
        List<Student> students = Arrays.asList(s1,s2,s3,s4,s5);

        students.sort((o1,o2)->o1.getScore()-o2.getScore());
        students.forEach(student -> System.out.println(student.getName()+"||"+student.getScore()));
        System.out.println("------------------分割线--------------------");
        students.sort(Student::compareScore);
        students.forEach(student -> System.out.println(student.getName()+"||"+student.getScore()));

        System.out.println("===========================大型分隔现场 一=======================");
        StudentComparator studentComparator = new StudentComparator();
        //Lambda表达式
        //students.sort((o1,o2)->studentComparator.compareScore(o1,o2));
        //方法引出
        students.sort(studentComparator::compareScore);
        students.forEach(student -> System.out.println(student.getName()+"||"+student.getScore()));

        System.out.println("===========================大型分隔现场 二=======================");
        //Lambda表达式
        students.sort((o1,o2)->o1.compareByScoreNew(o2));
       // students.sort(Student::compareByScoreNew);
        students.forEach(student -> System.out.println(student.getName()+"||"+student.getScore()));

        System.out.println("===========================大型分隔现场 三=======================");
        Supplier<Student> studentSupplier = Student::new;
        Student student = studentSupplier.get();
        student.setName("1");
        student.setScore(55);
        System.out.println("student:"+student.getScore());
    }


}
